<template>
	<view class="goods_detail">

		<swiper indicator-dots autoplay :interval=1500 circular >
			<swiper-item v-for="item in swipers" :key="item.id">
				<image :src="item.src">
				</iamge>
			</swiper-item>
		</swiper>
		
		<view class="box1">
			<view class="price">
				<text>¥6788</text>
				<text>¥8788</text>
			</view>
			<view class="goods_name">
				苹果Apple iPhone 6 Plus 16G 4G手机（联通三网版）
			</view>
		</view>
		<view class="line">
			
		<view class="box2">		
				<view class="">
					货号: SD853515313
				</view>
				<view class="">
					库存: 999
				</view>
		</view>
		<view class="line">
			
		</view>
		
		<view class="tit">
			{{goodsDetail.title}}
		</view>
		
		<view class="xiangxi">
			详细介绍
		</view>
		<view class="content" v-html="goodsDetail.content">
			{{goodsDetail.content}}
		</view>
		
		<view class="bar">
			<uni-goods-nav :fill="true"  :options="options" :buttonGroup="buttonGroup"/>
		</view>
	</view>
</template>

<script>
	import uniGoodsNav from '../../components/uni-goods-nav/uni-goods-nav.vue'
	export default {
		components: {uniGoodsNav},
		data() {
			return {
				goodsDetail:null,
				swipers:[],
				options: [{
				            icon: 'headphones',
				            text: '客服'
				        }, {
				            icon: 'shop',
				            text: '店铺',
				            info: 2,
				            infoBackgroundColor:'#007aff',
				            infoColor:"red"
				        }, {
				            icon: 'cart',
				            text: '购物车',
				            info: 2
				        }],
				        buttonGroup: [{
				          text: '加入购物车',
				          backgroundColor: '#ff0000',
				          color: '#fff'
				        },
				        {
				          text: '立即购买',
				          backgroundColor: '#ffa200',
				          color: '#fff'
				        }
				        ]
			}
		},
		onLoad(options) {
			console.log(options.id,777)
			this.goGoodsDetail(options.id)
			this.GoodsDetailSwiper(options.id)
			
		},
		methods: {
			async goGoodsDetail(id) {
				const res = await this.$http({
					url:`/api/goods/getdesc/${id}`
				})
				this.goodsDetail = res.data.message[0]
				console.log(res.data.message[0])
			},
			// 轮播图
			async GoodsDetailSwiper(id){
				const res = await this.$http({
					url:`/api/getthumimages/${id}`
				})
				this.swipers = res.data.message
				console.log(res.data.message)
			}
			
		}
	}
</script>

<style lang="scss">
	.xiangxi {
		padding: 0 10rpx;
		width: 750rpx;
		height: 60rpx;
		line-height: 70rpx;
		// padding-left: 10rpx;
		font-size: 42rpx;
	}
	swiper {
		width: 750rpx;
		height: 380rpx;
		text-align: center;
		margin-bottom: 30rpx;
		image {
			width: 100%;
			height: 100%;
		}
	}
	
	.goods_detail {
		width: 750rpx;
		// padding: 0  20rpx;
		
		.tit {
			padding: 0 10rpx;
			font-size: 40rpx;
			font-weight: bold;
			line-height: 70rpx;
		}
		.content {
			padding: 0 10rpx;
			margin-bottom: 50rpx;
			line-height: 60rpx;
			.gomeImgLoad {
				width: 750rpx;
				height: auto;
			}
		}
	}
	
	.box1 {
		padding: 10px;
		.price {
			font-size: 35rpx;
			color: $shop-color;
			line-height: 80rpx;
			text:nth-child(2) {
				color: #ccc;
				font-size: 28rpx;
				text-decoration: line-through;
				margin-left: 20rpx;
			}
		}
		.goods_name {
			font-size: 32rpx;
			line-height: 60rpx;
		}
	}
	.box2 {
		padding: 0 10px;
		font-size: 32rpx;
		line-height: 70rpx;
	}
	
	.line {
		height: 15rpx;
		width: 750rpx;
		background: #eee;
	}
	.bar {
		width: 750rpx;
		position: fixed;
		bottom: 0;
	}
</style>
